package com.example.demo.pojo;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
 * @author luolinila
 */
@Data
public class Player implements Serializable {
    //玩家id
    int id;
    //手里的筹码
    double chip;
    //已下的筹码
    double bet;
    //手牌
    List<Poker> handPoker;

    public Player(User user) {
        //身份确认
        this.id = user.getUid();
        //获取筹码
        this.chip = user.getBalance();
        //下注清空
        this.bet = 0;
        //手牌清空
        this.handPoker = new ArrayList<>();
    }

    //加注和下注
    public double add(double ante) {
        //小于时无法下注   等于时不能跟住和加注  等于时为AllIn
        if (chip <= ante) {
            return -1;
        }
        System.out.println(ante + " " + chip + " " + bet);
        chip -= ante;
        bet += ante;
        System.out.println(ante + " " + chip + " " + bet);
        return ante;
    }

    //ALLIn
    public double addAll() {
        if (chip <= 0) {
            return -1;
        }
        double temp = chip;
        chip = 0;
        bet += temp;
        return temp;
    }
}